<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  

  
  <title>CSS基础知识点--背景和列表 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="背景样式 background-color：设置元素的背景颜色  background-image：把图像设置为背景  background-position：设置背景图像的起始位置  background-attachment：背景图像是否固定或者随着页面的其余部分滚动  background-repeat：设置背景图像是否重复及如何重复  background：简写属性。作用是将背景属性设置">
<meta name="keywords" content="CSS">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS基础知识点--背景和列表">
<meta property="og:url" content="http://yoursite.com/2019/08/05/CSS基础知识点-背景和样式/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="背景样式 background-color：设置元素的背景颜色  background-image：把图像设置为背景  background-position：设置背景图像的起始位置  background-attachment：背景图像是否固定或者随着页面的其余部分滚动  background-repeat：设置背景图像是否重复及如何重复  background：简写属性。作用是将背景属性设置">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2019-08-05T14:03:54.473Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CSS基础知识点--背景和列表">
<meta name="twitter:description" content="背景样式 background-color：设置元素的背景颜色  background-image：把图像设置为背景  background-position：设置背景图像的起始位置  background-attachment：背景图像是否固定或者随着页面的其余部分滚动  background-repeat：设置背景图像是否重复及如何重复  background：简写属性。作用是将背景属性设置">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-CSS基础知识点-背景和样式" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2019/08/05/CSS基础知识点-背景和样式/" class="article-date">
  <time datetime="2019-08-05T08:57:43.000Z" itemprop="datePublished">2019-08-05</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS/">CSS</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      CSS基础知识点--背景和列表
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <hr>
<h2 id="背景样式"><a href="#背景样式" class="headerlink" title="背景样式"></a>背景样式</h2><ul>
<li><p>background-color：设置元素的背景颜色</p>
</li>
<li><p>background-image：把图像设置为背景</p>
</li>
<li><p>background-position：设置背景图像的起始位置</p>
</li>
<li><p>background-attachment：背景图像是否固定或者随着页面的其余部分滚动</p>
</li>
<li><p>background-repeat：设置背景图像是否重复及如何重复</p>
</li>
<li><p>background：简写属性。作用是将背景属性设置于一个声明</p>
</li>
</ul>
<h3 id="背景颜色"><a href="#背景颜色" class="headerlink" title="背景颜色"></a>背景颜色</h3><p>设置元素的背景颜色</p>
<blockquote>
<p>background-color：颜色 | transparent</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>transparent是全透明黑色（black）的速记法，类似rgba(0, 0, 0, 0)这样的值。</p>
</li>
<li><p>颜色值（颜色名 | RGB | 十六进制）</p>
</li>
<li><p>背景区包括内容、内边距（padding）和边框、不包括外边距（margin）</p>
</li>
</ul>
<h3 id="背景图片"><a href="#背景图片" class="headerlink" title="背景图片"></a>背景图片</h3><p>设置元素的背景图片</p>
<blockquote>
<p>background-image：URL | none</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>url地址可以是相对地址也可以是绝对地址</p>
</li>
<li><p>元素的背景占据了元素的全部尺寸，包括内边距和边框，但不包括外边距 </p>
</li>
<li><p>默认地，背景图像位于元素的左上角，并在水平和垂直方向上重复</p>
</li>
</ul>
<h3 id="背景图片重复"><a href="#背景图片重复" class="headerlink" title="背景图片重复"></a>背景图片重复</h3><p>设置元素的背景图片的重复方式</p>
<blockquote>
<p>background-repeat：repeat | no-repeat | repeat-x | repeat-y</p>
</blockquote>
<h3 id="背景图片显示方式"><a href="#背景图片显示方式" class="headerlink" title="背景图片显示方式"></a>背景图片显示方式</h3><p>设置元素的背景图片的显示方式</p>
<blockquote>
<p>background-attachment：scroll | fixed</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>scroll：默认值，背景图片随滚动条滚动</p>
</li>
<li><p>fixed：当页面的其余部分滚动时，背景图片不会移动</p>
</li>
</ul>
<h3 id="背景图片定位"><a href="#背景图片定位" class="headerlink" title="背景图片定位"></a>背景图片定位</h3><p>设置元素的背景图片的初始位置</p>
<blockquote>
<p>background-position：百分比 | 值 | top | right | bottom | left | center</p>
</blockquote>
<table>
<thead>
<tr>
<th>值</th>
<th>说明</th>
<th>注意</th>
</tr>
</thead>
<tbody><tr>
<td>长度值（x y）</td>
<td>第一个值水平位置，第二个值垂直位置</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>百分比（x% y%）</td>
<td>第一个时水平位置的百分比，第二个值垂直位置的百分比</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>top</td>
<td>顶部显示，相当于垂直方向0</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>right</td>
<td>右边显示，相当于水平方向100%</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>left</td>
<td>左边显示，相当于水平方向0</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>bottom</td>
<td>底边显示，相当于垂直方向100%</td>
<td>只写一个参数的话，第二个默认为居中</td>
</tr>
<tr>
<td>center</td>
<td>居中显示，相当于水平方向50%或者垂直方向50%</td>
<td>水平、垂直方向都居中</td>
</tr>
</tbody></table>
<h3 id="背景缩写"><a href="#背景缩写" class="headerlink" title="背景缩写"></a>背景缩写</h3><blockquote>
<p>background：[background-color] [background-image] [background-repeat] [background-attachment] [background-position]</p>
</blockquote>
<p>说明：</p>
<ul>
<li>各值之间用空格分割，不分先后顺序</li>
</ul>
<h2 id="列表样式"><a href="#列表样式" class="headerlink" title="列表样式"></a>列表样式</h2><ul>
<li><p>list-style-type：设置列表项标志的类型</p>
</li>
<li><p>list-style-image：将图像设置为列表项标志</p>
</li>
<li><p>list-style-position：设置列表中列表项标志的位置</p>
</li>
<li><p>list-style：简写属性。用于把所有列表的属性设置于一个声明</p>
</li>
</ul>
<h3 id="列表项标记"><a href="#列表项标记" class="headerlink" title="列表项标记"></a>列表项标记</h3><h4 id="设置列表项的标记样式类型"><a href="#设置列表项的标记样式类型" class="headerlink" title="设置列表项的标记样式类型"></a>设置列表项的标记样式类型</h4><blockquote>
<p>list-style-type：关键字 | none</p>
</blockquote>
<p>无序列表</p>
<table>
<thead>
<tr>
<th>值</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>none</td>
<td>无标记</td>
</tr>
<tr>
<td>disc</td>
<td>实心的圆点</td>
</tr>
<tr>
<td>circle</td>
<td>空心的圆点</td>
</tr>
<tr>
<td>square</td>
<td>实心的方块</td>
</tr>
</tbody></table>
<p>有序列表</p>
<table>
<thead>
<tr>
<th>值</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>none</td>
<td>无标记</td>
</tr>
<tr>
<td>decimal</td>
<td>从1开始的整数</td>
</tr>
<tr>
<td>lower-roman</td>
<td>小写罗马数字</td>
</tr>
<tr>
<td>upper-roman</td>
<td>大写罗马数字</td>
</tr>
<tr>
<td>lower-alpha</td>
<td>小写英文字母</td>
</tr>
<tr>
<td>upper-alpha</td>
<td>大写英文字母</td>
</tr>
</tbody></table>
<h4 id="使用图片设置列表项的标记"><a href="#使用图片设置列表项的标记" class="headerlink" title="使用图片设置列表项的标记"></a>使用图片设置列表项的标记</h4><blockquote>
<p>list-style-image：URL | none</p>
</blockquote>
<h3 id="列表项标记位置"><a href="#列表项标记位置" class="headerlink" title="列表项标记位置"></a>列表项标记位置</h3><p>设置列表项标记的位置</p>
<blockquote>
<p>list-style-position：inside | outside</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>inside：列表项目标记放置在文本以内，且环绕文本根据标记对齐</p>
</li>
<li><p>outside：默认值，列表项目标记放置在文本以外，且环绕文本不根据标记对齐</p>
</li>
</ul>
<h3 id="列表样式缩写"><a href="#列表样式缩写" class="headerlink" title="列表样式缩写"></a>列表样式缩写</h3><blockquote>
<p>list-style：list-style-type list-style-position list-style-image</p>
</blockquote>
<p>说明：</p>
<ul>
<li><p>值之间用空格分隔</p>
</li>
<li><p>顺序不固定</p>
</li>
<li><p>list-style-image会覆盖list-style-type的设置</p>
</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2019/08/05/CSS基础知识点-背景和样式/" data-id="ck4r400nf000jl0w09zfv894o" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS/">CSS</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2019/08/06/CSS基础知识点-float浮动/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          CSS基础知识点--float浮动
        
      </div>
    </a>
  
  
    <a href="/2019/08/03/CSS基础知识点-盒子模型/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">CSS基础知识点--盒子模型</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Ajax/">Ajax</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS/">CSS</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/CSS3/">CSS3</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Dart/">Dart</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Flutter/">Flutter</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Git/">Git</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML/">HTML</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/HTML5/">HTML5</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JSON/">JSON</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/QT/">QT</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/React/">React</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Sass/">Sass</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/TheKnowledgeOf/">TheKnowledgeOf</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/TypeScript/">TypeScript</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/bootstrap/">bootstrap</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/jQuery/">jQuery</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Ajax/">Ajax</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS/">CSS</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/CSS3/">CSS3</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Dart/">Dart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Flutter/">Flutter</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Git/">Git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML/">HTML</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/HTML5/">HTML5</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JSON/">JSON</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/">Java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Javascript/">Javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/QT/">QT</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/">React</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Sass/">Sass</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TheKnowledgeOf/">TheKnowledgeOf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/TypeScript/">TypeScript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/bootstrap/">bootstrap</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/jQuery/">jQuery</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Ajax/" style="font-size: 12.22px;">Ajax</a> <a href="/tags/CSS/" style="font-size: 18.89px;">CSS</a> <a href="/tags/CSS3/" style="font-size: 17.78px;">CSS3</a> <a href="/tags/Dart/" style="font-size: 14.44px;">Dart</a> <a href="/tags/Flutter/" style="font-size: 16.67px;">Flutter</a> <a href="/tags/Git/" style="font-size: 12.22px;">Git</a> <a href="/tags/HTML/" style="font-size: 14.44px;">HTML</a> <a href="/tags/HTML5/" style="font-size: 12.22px;">HTML5</a> <a href="/tags/JSON/" style="font-size: 10px;">JSON</a> <a href="/tags/Java/" style="font-size: 11.11px;">Java</a> <a href="/tags/JavaScript/" style="font-size: 20px;">JavaScript</a> <a href="/tags/Javascript/" style="font-size: 10px;">Javascript</a> <a href="/tags/QT/" style="font-size: 12.22px;">QT</a> <a href="/tags/React/" style="font-size: 15.56px;">React</a> <a href="/tags/Sass/" style="font-size: 11.11px;">Sass</a> <a href="/tags/TheKnowledgeOf/" style="font-size: 11.11px;">TheKnowledgeOf</a> <a href="/tags/TypeScript/" style="font-size: 10px;">TypeScript</a> <a href="/tags/bootstrap/" style="font-size: 11.11px;">bootstrap</a> <a href="/tags/jQuery/" style="font-size: 13.33px;">jQuery</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/12/">December 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">October 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">September 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">May 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">April 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">March 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2019/12/29/Flutter-MaterialApp常用属性介绍/">Flutter-MaterialApp常用属性介绍</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-ListView/">Flutter-ListView</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-AppBar/">Flutter-AppBar</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-TabBar/">Flutter-TabBar</a>
          </li>
        
          <li>
            <a href="/2019/12/29/Flutter-按钮/">Flutter-按钮</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2019 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>